package com.azxc.rapid.resource.feign;


import com.azxc.rapid.core.launch.constant.AppConstant;
import com.azxc.rapid.core.oss.model.RapidFile;
import com.azxc.rapid.core.tool.api.R;
import com.azxc.rapid.resource.config.FeignMultipartSupportConfig;
import com.azxc.rapid.resource.entity.Attach;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;

@FeignClient(
	value = AppConstant.APPLICATION_RESOURCE_NAME,
	fallback = IAttachClientFallback.class,
	configuration = FeignMultipartSupportConfig.class
)
public interface IAttachClient {

	String API_PREFIX = "/client";
	String GET_ATTACH_BY_ID = API_PREFIX + "/get-attach-by-id";
	String GET_SOURCE_ATTACH_BY_ID = API_PREFIX + "/get-source-attach-by-id";
	String PUTFILE = API_PREFIX + "/put-attach";
	String UN_LOGIN_PUTFILE = API_PREFIX + "/un-login-put-attach";
	String PUT_BASE64 = API_PREFIX + "/put-base64";

	@PostMapping(GET_ATTACH_BY_ID)
    R<Attach> getAttachById(@RequestParam("id") Long id);

	@PostMapping(GET_SOURCE_ATTACH_BY_ID)
	R<Attach> getSourceAttachById(@RequestParam("id") Long id);

	@PostMapping(value=PUTFILE,consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
	R<RapidFile> putFile(@RequestPart("file") MultipartFile file);

	@PostMapping(value=UN_LOGIN_PUTFILE,consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
	R<RapidFile> unLoginPutFile(@RequestPart("file") MultipartFile file);

	@GetMapping(value = PUT_BASE64)
	R<RapidFile> putBase64(@RequestParam("fileName") String fileName,@RequestParam("key") String key);
}
